//
//  AreaWithShoppinTableViewCell.m
//  FreeTrip
//
//  Created by 352324497@qq.com on 15/11/24.
//  Copyright © 2015年 邓芮. All rights reserved.
//

#import "AreaWithShoppinTableViewCell.h"
@interface AreaWithShoppinTableViewCell ()

// 图片
@property (nonatomic, strong)UIImageView *backgroundImageView;
// 中文地名
@property (nonatomic, strong)UILabel *name_zh_cnLabel;
// 英语地名
@property (nonatomic, strong)UILabel *name_enLabel;

@end

@implementation AreaWithShoppinTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.selectionStyle = NO;
        
        CGFloat height = (KScreenWidth - 20 * KScreenWidth / 375) / 600 * 360;
        self.backgroundImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10 * KScreenWidth / 375, 10 * KScreenWidth / 375, KScreenWidth - 10 * 2 * KScreenWidth / 375, height)];
        [self.contentView addSubview:_backgroundImageView];
        
        UIView *coverView = [[UIView alloc]initWithFrame:self.backgroundImageView.frame];
        coverView.backgroundColor = [UIColor blackColor];
        coverView.alpha = 0.1;
        [self.contentView addSubview:coverView];
        
        
        CGFloat width = self.backgroundImageView.frame.size.width;
        self.name_zh_cnLabel = [[UILabel alloc]initWithFrame:CGRectMake(width / 10, KScreenWidth / 16 , width / 3 * 2, width / 10)];
        self.name_zh_cnLabel.textColor = [UIColor whiteColor];
        self.name_zh_cnLabel.font = [UIFont boldSystemFontOfSize:26 * KScreenWidth / 375];
        [self.contentView addSubview:_name_zh_cnLabel];
        
        self.name_enLabel = [[UILabel alloc]initWithFrame:CGRectMake(width / 10, KScreenWidth / 16 + width / 10 , width / 3 * 2, width / 10)];
        self.name_enLabel.textColor = [UIColor whiteColor];
        self.name_enLabel.font = [UIFont systemFontOfSize:26 * KScreenWidth / 375];
        [self.contentView addSubview:_name_enLabel];
        
        CGFloat btnWidth = width / 4;
        // 攻略的 button
        self.strategyButton = [DIYButton buttonWithType:(UIButtonTypeCustom)];
        self.strategyButton.frame = CGRectMake(10 * KScreenWidth / 375, height + 20 * KScreenWidth / 375, btnWidth, btnWidth);
        self.strategyButton.customImageView.image = [UIImage imageNamed:@"strategy"];
        self.strategyButton.textLabel.text = @"攻略";
        [self.contentView addSubview:_strategyButton];
        
        // 口袋书的 button
        self.bookButton = [DIYButton buttonWithType:(UIButtonTypeCustom)];
        self.bookButton.frame = CGRectMake(10 * KScreenWidth / 375 + btnWidth, height + 20 * KScreenWidth / 375, btnWidth, btnWidth);
        self.bookButton.customImageView.image = [UIImage imageNamed:@"book"];
        self.bookButton.textLabel.text = @"口袋书";
        [self.contentView addSubview:_bookButton];
        
        // 地图 button
        self.mapButton = [DIYButton buttonWithType:(UIButtonTypeCustom)];
        self.mapButton.frame = CGRectMake(10 * KScreenWidth / 375 + btnWidth * 2, height + 20, btnWidth, btnWidth);
        self.mapButton.customImageView.image = [UIImage imageNamed:@"map"];
        self.mapButton.textLabel.text = @"行程地图";
        [self.contentView addSubview:_mapButton];
        
        // 工具箱 button
        self.toolButton = [DIYButton buttonWithType:(UIButtonTypeCustom)];
        self.toolButton.frame = CGRectMake(10 * KScreenWidth / 375 + btnWidth * 3, height + 20 * KScreenWidth / 375, btnWidth, btnWidth);
        self.toolButton.customImageView.image = [UIImage imageNamed:@"tianqi"];
        self.toolButton.textLabel.text = @"天气";
        [self.contentView addSubview:_toolButton];
    }
    return self;
}

+(CGFloat)heightForCell
{
    return (KScreenWidth - 10 * 2 ) / 600 * 360 + (KScreenWidth - 10 * 2)/ 4;
}
-(void)setModel:(abAndeInModel *)model
{
    _model = model;
    [self.backgroundImageView sd_setImageWithURL:[NSURL URLWithString:model.image_url] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    self.name_zh_cnLabel.text = model.name_zh_cn;
    self.name_enLabel.text = model.name_en;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
